package org.codegallery.javagal.thread;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class SwingFrame {
	public static void main(String[] args){
		JFrame f=new JFrame();
		f.setLayout(new FlowLayout());
		JButton btn=new JButton("Click");
		f.add(btn);
		btn.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				SwingUtilities.invokeLater(new Runnable(){
					public void run() {
						while(true){
							System.out.println("Haha....");
							try {
								Thread.sleep(1000L);
							} catch (InterruptedException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						
					}
					
				});
				
			}
			
		});
	}
}
